const path = require('path');
const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const cors = require('koa2-cors');
const static = require('koa-static');
const warmingRouter = require('./routes/warming');
const orderRouter = require('./routes/order');
const fileRouter = require('./routes/file');
const userRouter = require('./routes/user');
const payRouter = require('./routes/pay');
const addressRouter = require('./routes/address');
const qrcodeRouter = require('./routes/qrcode');
const giftRouter = require('./routes/gift');
const app = new Koa();

app.use(cors());
app.use(bodyParser());
app.use(warmingRouter.routes()).use(warmingRouter.allowedMethods());
app.use(orderRouter.routes()).use(orderRouter.allowedMethods());
app.use(fileRouter.routes()).use(fileRouter.allowedMethods());
app.use(userRouter.routes()).use(userRouter.allowedMethods());
app.use(payRouter.routes()).use(payRouter.allowedMethods());
app.use(addressRouter.routes()).use(addressRouter.allowedMethods());
app.use(qrcodeRouter.routes()).use(qrcodeRouter.allowedMethods());
app.use(giftRouter.routes()).use(giftRouter.allowedMethods());
app.use(static(path.join(__dirname, './uploads'))); 
app.listen(3000, () => {
  console.log('🚀 Server running at http://localhost:3000');
});
